package com.sh.util;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final public class CommandLineUtil {
    static private final Logger LOGGER = LoggerFactory.getLogger(CommandLineUtil.class);


    static public CommandLine createCmdLn(String[] argvArry) {
        Options op = new Options();
        op.addRequiredOption(null, "server_id", true, "服务器id");
        op.addRequiredOption(null, "bind_host", true, "绑定主机地址");
        op.addRequiredOption(null, "bind_port", true, "绑定主机端口");
        op.addRequiredOption(null, "nacos_server_addr", true, "绑定注册中心地址");
        op.addRequiredOption(null, "job_type", true, "服务器类型");

        try {
            DefaultParser dp = new DefaultParser();
            return dp.parse(op, argvArry);
        } catch (ParseException ex) {
            LOGGER.error(ex.getMessage(), ex);
        }
        return null;
    }
}
